package com.gopay.common.rcs.dao.loginmacinfo.impl;

import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.domain.rcs.RcUserLoginMacDtl;
import com.gopay.common.rcs.dao.loginmacinfo.RcUserLoginMacDtlDao;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * CLASSNAME:RcUserLoginMacDtlDaoImpl
 * Description:实现类
 * DATE:2017/7/11/011
 * AUTHER:PANSHICHAO
 * www.gopay.com.cn Inc.All rights reserved.
 */
@Repository(value = "rcUserLoginMacDtlDao")
public class RcUserLoginMacDtlDaoImpl extends BaseDAOImpl<RcUserLoginMacDtl,String> implements RcUserLoginMacDtlDao{

    @Override
    public RcUserLoginMacDtl getMacInfoByUserIdAndMacInfo(String userId, String macInfo) {
        String hql = "from RcUserLoginMacDtl where userId = :userId and mac = :mac";
        Map<String,Object> param = new HashMap<String,Object>();
        param.put("userId",userId);
        param.put("mac",macInfo);
        List<RcUserLoginMacDtl> resultList = super.findByHql(hql,param);
        if(resultList != null){
            if (resultList.size() != 0){
                return resultList.get(0);
            }
        }
        return null;
    }

    @Override
    public List<RcUserLoginMacDtl> getRcUserLoginMacDtlByMac(String mac) {
        String hql = "from RcUserLoginMacDtl where  mac = :mac";
        Map<String,Object> param = new HashMap<String,Object>();
        param.put("mac",mac);
        List<RcUserLoginMacDtl> resultList = super.findByHql(hql,param);
        if(resultList != null){
           return  resultList;
            }
        return null;
    }
}
